package org.atguigu.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @Author 海晨忆
 * @Des spring容器关闭的时候触发该监听器
 * @Date 2025/8/8 16:30
 */
@Slf4j
@Component
public class ApplicationShutListener implements ApplicationListener<ContextClosedEvent> {
    @Autowired
    private StringRedisTemplate redisTemplate;

    @Override
    public void onApplicationEvent(ContextClosedEvent event) {
        log.info("spring容器关闭了");
        //容器关闭，删除token
//        redisTemplate.delete(Constant.REDIS_TOKEN_KEY);
    }
}
